<template>
    <el-aside>
        <el-menu ref="menu" :router="true" active-text-color="#ffd04b" background-color="#95106b"
            class="el-menu-vertical-demo" :collapse='!isCollapse' text-color="#fff" @select="handleChangeType">
            <div class="collapse-area">
                <ArrowLeftBold color="white" class="switch-icon" v-if="isCollapse" @click="isCollapse = false">
                </ArrowLeftBold>
                <ArrowRightBold color="white" class="switch-icon" v-else @click="isCollapse = true"></ArrowRightBold>
            </div>
            <el-menu-item index="testTemplate" :="{ path: '/designer' }" key="testTemplate">
                <el-icon>
                    <money />
                </el-icon>
                <span>检测模板</span>
            </el-menu-item>
            <el-menu-item index="importData" :="{ path: '/spread' }" key="importData">
                <el-icon>
                    <data-board />
                </el-icon>
                <span>导入检测数据</span>
            </el-menu-item>
            <div class="github-box">
                <a href="https://github.com/SpreadJSHero/data-submit-spreadjs" target="_blank">
                    <img width="40" src="../../assets/github.png" />
                </a>
            </div>
        </el-menu>
    </el-aside>
</template>

<script>
import { defineComponent, reactive, toRefs } from "vue"
import { useRouter } from "vue-router"
import { ElAside, ElMenu, ElMenuItem, ElIcon } from "element-plus"
import { Money, DataBoard, ArrowRightBold, ArrowLeftBold } from "@element-plus/icons-vue"
import router from "../../router"

export default defineComponent({
    components: {
        Money, DataBoard, ArrowRightBold, ArrowLeftBold,
        ElAside, ElMenu, ElMenuItem, ElIcon
    },

    setup() {
        const router = useRouter();
        const pageData = reactive({
            isCollapse: true,
        })
        const handleChangeType = (event) => {
            debugger;
            if (event == "importData") {
                router.push({ path: 'spread', query: { template: "testTemplate" } })
            }
            else {
                router.push({ path: 'designer', query: { template: "testTemplate" } })
            }

        }
        return ({
            ...toRefs(pageData),
            handleChangeType
        })
    }
})
</script>

<style>
.el-aside {
    width: auto !important;
}

.collapse-area {
    height: 40px;
    line-height: 40px;
}

.github-box {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
}

.switch-icon {
    width: 20px;
    margin-left: 20px;
    padding-top: 10px;
    display: block;
    cursor: pointer;
}

.el-menu-vertical-demo {
    height: 100%;
}
</style>